package basic;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gzkemays
 * @since 2021/12/13 18:29
 */
@Data
@Builder
@AllArgsConstructor
public class QrCodeBasic {
  @NonNull String accessToken;
  @NonNull Integer mode;
  String generatePath;
  String path;
  String page;
  String scene;
  String width;
  Boolean autoColor;
  Boolean isHyaline;
  Boolean checkPath;
  String envVersion;
  QrCodeLineColor lineColor;

  public Map<String, String> transitionMap() {
    Map<String, String> map = new HashMap<>(9);
    if (page != null) {
      map.put("page", page);
    }
    if (path != null) {
      map.put("path", path);
    }
    if (autoColor != null) {
      map.put("auto_color", String.valueOf(autoColor));
    }
    if (isHyaline != null) {
      map.put("is_hyaline", String.valueOf(isHyaline));
    }
    if (checkPath != null) {
      map.put("check_path", String.valueOf(checkPath));
    }
    if (scene != null) {
      map.put("scene", scene);
    }
    if (width != null) {
      map.put("width", width);
    }
    if (envVersion != null) {
      map.put("env_version", envVersion);
    }
    if (lineColor != null) {
      map.put("line_color", lineColor.getColor());
    }
    return map;
  }
}
